<?php

namespace app\common\model;

/**
 * [寺院供灯订单表]
 * @author [C。]
 * @return html
 */
class CompanyGongdengOrder extends Base
{
    protected $name = 'company_gongdeng_order';
    /**
     * 根据搜索条件获取佛事预约列表信息
     */
    public function getlist($map,$from = 0, $size = 5,$field = '*',$is_zhu = 1)
    {
        $order = ['c.id' => 'desc'];
        $join = [
            ['app_member m','m.id = c.mid'],
        ];
        if($is_zhu == 1){
            $result =  $this->field($field)
                ->alias('c')
                ->join($join)
                ->where($map)
                ->order($order)
                ->limit($from, $size)
                ->select();
        }else{
            $join1 = [
                ['app_company co','co.id = c.comid'],
            ];
            $result =  $this->field($field)
                ->alias('c')
                ->join($join)
                ->join($join1)
                ->where($map)
                ->order($order)
                ->limit($from, $size)
                ->select();
        }


        return $result;
    }
    /**
     * 根据搜索条件获取佛事预约列表信息
     */
    public function getCount($map,$is_zhu = 1)
    {
        $join = [
            ['app_member m','m.id = c.mid'],
        ];
        if($is_zhu == 1){
            $result =  $this
                ->alias('c')
                ->join($join)
                ->where($map)
                ->count();
        }else{
            $join1 = [
                ['app_company co','co.id = c.comid'],
            ];
            $result =  $this
                ->alias('c')
                ->join($join)
                ->join($join1)
                ->where($map)
                ->count();
        }

        return $result;
    }
    /**
     * 根据搜索条件获取佛事预约列表信息
     */
    public function getall($map,$field = '*',$order = ['c.id'=>'desc'])
    {
        $join = [
            ['app_member m', 'm.id = c.mid'],
        ];
        $result = $this->field($field)
            ->alias('c')
            ->join($join)
            ->where($map)
            ->order($order)
            ->select();
        return $result;
    }
}